package com.zcx.qshop.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2015/11/16.
 */
@HttpInlet(Conn.INLET_JSON_RECHARGE)
public class JsonRechargeAsyGet extends QSAsyGet<List<JsonRechargeAsyGet.Info>> {

    public JsonRechargeAsyGet(AsyCallBack<List<Info>> asyCallBack) {

        super(asyCallBack);

    }

    @Override
    protected List<Info> parser(JSONObject object) {

        if(object.optString("message").equals("1")){

            List<Info> list = new ArrayList<>();

            JSONArray array = object.optJSONArray("rechargelist");

            for (int i = 0 ; i < array.length() ; i ++){

                JSONObject o = array.optJSONObject(i);

                Info info = new Info();

                info.acount = o.optString("acount");

                info.free = o.optString("free");

                list.add(info);

            }

            return list;

        }

        return null;

    }

    public static class Info{

        public String acount, free;

    }

}
